- move glcd sources to one single place in driver/glcd

Conflicts:
	src/driver/Makefile.am

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2020-06-21 17:39:51 +02:00
committed by Thilo Graf
parent 3e6bab00d8
commit ff94004d7f
21 changed files with 43 additions and 22 deletions

View File

@@ -0,0 +1,25 @@
AM_CXXFLAGS = -fno-rtti -fno-exceptions
AM_CPPFLAGS = \
-I$(top_builddir) \
-I$(top_srcdir) \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/zapit/include \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/lib/libconfigfile \
-I$(top_srcdir)/lib/libeventserver \
@SIGC_CFLAGS@ \
@FREETYPE_CFLAGS@ \
@LUA_CFLAGS@ \
@HWLIB_CFLAGS@
noinst_LIBRARIES = libneutrino_driver_glcd.a
libneutrino_driver_glcd_a_SOURCES = \
analogclock.cpp \
digitalclock.cpp \
lcdclock.cpp \
ledclock.cpp \
simpleclock.cpp \
weather.cpp \
glcd.cpp

View File

@@ -0,0 +1,179 @@
/*
analog clock - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean',
2003 thegoodguy
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 <math.h>
#include <cstdio>
#include "analogclock.h"
#include <system/helpers.h>
enum files
{
ANALOG_CLOCK = 0,
ANALOG_HOUR = 1,
ANALOG_MIN = 2
};
const char * const file_name[LCD_NUMBER_OF_FILES] =
{
"analog_clock",
"analog_hour",
"analog_min"
};
#define NUMBER_OF_PATHS 2
const char * const file_path[NUMBER_OF_PATHS] =
{
LCDDIR_VAR "/oled/clock/",
DATADIR "/oled/clock/"
};
static std::string file[LCD_NUMBER_OF_FILES] = {""};
void InitAnalogClock(void)
{
for (int i = 0; i < LCD_NUMBER_OF_FILES; i++)
{
std::string tmp_file;
for (int j = 0; j < NUMBER_OF_PATHS; j++)
{
std::string file_jpg = file_path[j];
file_jpg += file_name[i];
file_jpg += ".jpg";
if (file_exists(file_jpg.c_str()))
{
tmp_file = file_jpg;
goto found;
}
std::string file_jpeg = file_path[j];
file_jpeg += file_name[i];
file_jpeg += ".jpeg";
if (file_exists(file_jpeg.c_str()))
{
tmp_file = file_jpeg;
goto found;
}
std::string file_png = file_path[j];
file_png += file_name[i];
file_png += ".png";
if (file_exists(file_png.c_str()))
{
tmp_file = file_png;
goto found;
}
std::string file_bmp = file_path[j];
file_bmp += file_name[i];
file_bmp += ".bmp";
if (file_exists(file_bmp.c_str()))
{
tmp_file = file_bmp;
goto found;
}
std::string file_gif = file_path[j];
file_gif += file_name[i];
file_gif += ".gif";
if (file_exists(file_gif.c_str()))
{
tmp_file = file_gif;
goto found;
}
}
found:
printf("[%s:%s] found file: %s\n", __file__, __func__, tmp_file.c_str());
file[i] += std::string(tmp_file);
}
printf("[%s:%s] finish initialization\n", __file__, __func__);
}
void RenderClock(int x, int y)
{
cGLCD *cglcd = cGLCD::getInstance();
cglcd->imageShow(file[ANALOG_CLOCK], x, y, 0, 0, false, true, false, false, false);
}
void RenderHands(int hour, int min, int sec, int posx, int posy, int hour_size, int min_size, int sec_size)
{
cGLCD *cglcd = cGLCD::getInstance();
int time_sec, time_min, time_hour, sec_x, sec_y, min_x, min_y, hour_x, hour_y, dia;
double pi = 3.1415926535897932384626433832795, sAngleInRad, mAngleInRad, mAngleSave, hAngleInRad;
time_sec = sec;
time_min = min;
time_hour = hour;
dia = 180;
sAngleInRad = ((6 * time_sec) * (2 * pi / 360));
sAngleInRad -= pi / 2;
sec_x = int((dia * 0.9 * cos(sAngleInRad)));
sec_y = int((dia * 0.9 * sin(sAngleInRad)));
mAngleInRad = ((6 * time_min) * (2 * pi / 360));
mAngleSave = mAngleInRad;
mAngleInRad -= pi/2;
min_x = int((dia * 0.7 * cos(mAngleInRad)));
min_y = int((dia * 0.7 * sin(mAngleInRad)));
hAngleInRad = ((30 * time_hour) * (2 * pi / 360));
hAngleInRad += mAngleSave/12;
hAngleInRad -= pi/2;
hour_x = int((dia * 0.5 * cos(hAngleInRad)));
hour_y = int((dia * 0.5 * sin(hAngleInRad)));
//hour
for (int i = 0; i <= hour_size; i++)
{
#if 1
cglcd->bitmap->DrawLine(posx-i, posy-i, posx + hour_x,posy + hour_y, GLCD::cColor::White);
cglcd->bitmap->DrawLine(posx+i, posy+i, posx + hour_x,posy + hour_y, GLCD::cColor::White);
#else
cglcd->bitmap->DrawLine(posx-i, posy-i, posx + hour_x-i,posy + hour_y-i, t.glcd_color_fg);
cglcd->bitmap->DrawLine(posx+i, posy+i, posx + hour_x+i,posy + hour_y+i, t.glcd_color_fg);
#endif
}
//min
for (int i = 0; i <= min_size; i++)
{
#if 1
cglcd->bitmap->DrawLine(posx-i, posy-i, posx + min_x,posy + min_y, GLCD::cColor::White);
cglcd->bitmap->DrawLine(posx+i, posy+i, posx + min_x,posy + min_y, GLCD::cColor::White);
#else
cglcd->bitmap->DrawLine(posx-i, posy-i, posx + min_x-i,posy + min_y-i, t.glcd_color_fg);
cglcd->bitmap->DrawLine(posx+i, posy+i, posx + min_x+i,posy + min_y+i, t.glcd_color_fg);
#endif
}
}
void ShowAnalogClock(int hour, int min, int sec, int x, int y)
{
RenderClock(0, 0);
RenderHands(hour, min, sec, x, y, 5, 3, 1);
}

View File

@@ -0,0 +1,35 @@
/*
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.
*/
#include "glcd.h"
#define LCDDIR_VAR "/usr/share/tuxbox/neutrino/icons"
#define LCD_NUMBER_OF_FILES 3
void InitAnalogClock();
void RenderClock(int x, int y);
void RenderHands(int hour, int min, int sec, int posx, int posy, int hour_size, int min_size, int sec_size);
void ShowAnalogClock(int hour, int min, int sec, int x, int y);

View File

@@ -0,0 +1,164 @@
/*
digital clock - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean',
2003 thegoodguy
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 "digitalclock.h"
#include <system/helpers.h>
#include <driver/pictureviewer/pictureviewer.h>
enum digits
{
TIME_ZERO = 0,
TIME_ONE = 1,
TIME_TWO = 2,
TIME_THREE = 3,
TIME_FOUR = 4,
TIME_FIVE = 5,
TIME_SIX = 6,
TIME_SEVEN = 7,
TIME_EIGHT = 8,
TIME_NINE = 9,
TIME_DOTS = 10
};
const char * const digit_name[LCD_NUMBER_OF_DIGITS] =
{
"time_zero",
"time_one",
"time_two",
"time_three",
"time_four",
"time_five",
"time_six",
"time_seven",
"time_eight",
"time_nine",
"time_dots"
};
#define NUMBER_OF_PATHS 2
const char * const digit_path[NUMBER_OF_PATHS] =
{
LCDDIR_VAR "/oled/clock/",
DATADIR "/oled/clock/"
};
static std::string digit[LCD_NUMBER_OF_DIGITS] = {""};
void InitDigitalClock(void)
{
for (int i = 0; i < LCD_NUMBER_OF_DIGITS; i++)
{
std::string digit_file;
for (int j = 0; j < NUMBER_OF_PATHS; j++)
{
std::string file_jpg = digit_path[j];
file_jpg += digit_name[i];
file_jpg += ".jpg";
if (file_exists(file_jpg.c_str()))
{
digit_file = file_jpg;
goto found;
}
std::string file_jpeg = digit_path[j];
file_jpeg += digit_name[i];
file_jpeg += ".jpeg";
if (file_exists(file_jpeg.c_str()))
{
digit_file = file_jpeg;
goto found;
}
std::string file_png = digit_path[j];
file_png += digit_name[i];
file_png += ".png";
if (file_exists(file_png.c_str()))
{
digit_file = file_png;
goto found;
}
std::string file_bmp = digit_path[j];
file_bmp += digit_name[i];
file_bmp += ".bmp";
if (file_exists(file_bmp.c_str()))
{
digit_file = file_bmp;
goto found;
}
std::string file_gif = digit_path[j];
file_gif += digit_name[i];
file_gif += ".gif";
if (file_exists(file_gif.c_str()))
{
digit_file = file_gif;
goto found;
}
}
found:
printf("[%s:%s] found file: %s\n", __file__, __func__, digit_file.c_str());
digit[i] += std::string(digit_file);
}
printf("[%s:%s] finish initialization\n", __file__, __func__);
}
void RenderTimeDigit(int _digit, int x, int y)
{
cGLCD *cglcd = cGLCD::getInstance();
if (g_settings.glcd_standby_weather)
cglcd->imageShow(digit[_digit], x, y, 0, 0, false, false, false, false, false);
else
cglcd->imageShow(digit[_digit], x, y, 0, 0, false, false, false, false, true);
}
void RenderDots(int x, int y)
{
cGLCD *cglcd = cGLCD::getInstance();
if (g_settings.glcd_standby_weather)
cglcd->imageShow(digit[TIME_DOTS], x, y, 0, 0, false, false, false, true, false);
else
cglcd->imageShow(digit[TIME_DOTS], x, y, 0, 0, false, false, false, true, true);
}
void ShowDigitalClock(int hour, int minute)
{
cGLCD *cglcd = cGLCD::getInstance();
SNeutrinoGlcdTheme &t = g_settings.glcd_theme;
int y = g_settings.glcd_standby_weather ? t.glcd_digital_clock_y_position : cglcd->bitmap->Height() / 2;
int a = 10;
int b = 117;
int c = cglcd->bitmap->Width() / 2; //center dots
int d = 258;
int e = 365;
RenderTimeDigit(hour/10, a, y);
RenderTimeDigit(hour%10, b, y);
RenderDots(c ,(g_settings.glcd_standby_weather ? (y + 35) : y));
RenderTimeDigit(minute/10, d, y);
RenderTimeDigit(minute%10, e, y);
}

View File

@@ -0,0 +1,38 @@
/*
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"
#define LCDDIR_VAR "/usr/share/tuxbox/neutrino/icons"
#define LCD_NUMBER_OF_DIGITS 11
void InitDigitalClock();
void RenderTimeDigit(int _digit, int x, int y);
void RenderDots(int x, int y);
void ShowDigitalClock(int hour, int minute);

1727
src/driver/glcd/glcd.cpp Normal file

File diff suppressed because it is too large Load Diff

226
src/driver/glcd/glcd.h Normal file
View File

@@ -0,0 +1,226 @@
/*
nglcd.h -- Neutrino GraphLCD driver
Copyright (C) 2012-2014 martii
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 ENABLE_GRAPHLCD
#ifndef __glcd_h__
#define __glcd_h__
#include <string>
#include <vector>
#include <time.h>
#include <string>
#include <sys/types.h>
#include <semaphore.h>
#include <zapit/include/zapit/client/zapittypes.h>
#include <neutrinoMessages.h>
#define CLAMP(x) ((x < 0) ? 0 : ((x > 255) ? 255 : x))
#define SWAP(x,y) { x ^= y; y ^= x; x ^= y; }
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <glcdgraphics/bitmap.h>
#include <glcdgraphics/font.h>
#include <glcddrivers/config.h>
#include <glcddrivers/driver.h>
#include <glcddrivers/drivers.h>
#pragma GCC diagnostic warning "-Wunused-parameter"
class cGLCD
{
private:
int fontsize_channel;
int fontsize_epg;
int fontsize_time;
int fontsize_duration;
int fontsize_start;
int fontsize_end;
int fontsize_smalltext;
int percent_channel;
int percent_time;
int percent_duration;
int percent_start;
int percent_end;
int percent_epg;
int percent_smalltext;
int percent_bar;
int percent_logo;
int power_state;
std::string Logo;
std::string Channel;
std::string Epg;
std::string Time;
std::string Duration;
std::string Start;
std::string End;
std::string Smalltext;
std::string Temperature;
std::string stagingChannel;
std::string stagingEpg;
std::string stagingTime;
std::string stagingDuration;
std::string stagingStart;
std::string stagingEnd;
std::string stagingSmalltext;
t_channel_id channel_id;
int Scale;
time_t now;
struct tm *tm;
int EpgWidth;
int ChannelWidth;
int TimeWidth;
int DurationWidth;
int StartWidth;
int EndWidth;
int SmalltextWidth;
int scrollEpgSkip;
int scrollChannelSkip;
int scrollEpgOffset;
int scrollChannelOffset;
bool scrollEpgForward;
bool scrollChannelForward;
bool blitFlag;
bool channelLocked;
bool timeLocked;
bool durationLocked;
bool startLocked;
bool endLocked;
bool recLocked;
bool muteLocked;
bool tsLocked;
bool ecmLocked;
bool timerLocked;
bool ddLocked;
bool txtLocked;
bool subLocked;
bool camLocked;
bool doRescan;
bool doSuspend;
bool doStandby;
bool doStandbyTime;
bool doExit;
bool doScrollChannel;
bool doScrollEpg;
bool doShowVolume;
bool doShowLcdIcon;
bool doMirrorOSD;
bool fonts_initialized;
bool ismediaplayer;
int timeout_cnt;
bool locked_countdown;
bool time_thread_started;
pthread_t thrGLCD;
pthread_t thrTimeThread;
pthread_mutex_t mutex;
sem_t sem;
void updateFonts();
bool showImage(fb_pixel_t *s,
uint32_t sw, uint32_t sh,
uint32_t dx, uint32_t dy, uint32_t dw, uint32_t dh,
bool transp = false, bool maximize = false);
bool showImage(const std::string & filename,
uint32_t sw, uint32_t sh,
uint32_t dx, uint32_t dy, uint32_t dw, uint32_t dh,
bool transp = false, bool maximize = false);
bool showImage(uint64_t channel_id, std::string ChannelName,
uint32_t dx, uint32_t dy, uint32_t dw, uint32_t dh,
bool transp = false, bool maximize = false);
bool getBoundingBox(uint32_t *buffer,
int width, int height,
int &bb_x, int &bb_y, int &bb_width, int &bb_height);
void Exec();
void CountDown();
void WakeUp();
static void *TimeThread(void *);
void Run(void);
static void* Run(void *);
static void Lock();
static void Unlock();
public:
enum {
BMP = 0,
JPG = 1,
PNG = 2,
};
enum {
ALIGN_NONE = 0,
ALIGN_LEFT = 1,
ALIGN_CENTER = 2,
ALIGN_RIGHT = 3,
};
enum {
REC = 0,
MUTE = 1,
TS = 2,
ECM = 3,
TIMER = 4,
DD = 5,
TXT = 6,
SUB = 7,
CAM = 8,
};
GLCD::cDriver * lcd;
GLCD::cFont font_channel;
GLCD::cFont font_epg;
GLCD::cFont font_time;
GLCD::cFont font_duration;
GLCD::cFont font_start;
GLCD::cFont font_end;
GLCD::cFont font_smalltext;
GLCD::cBitmap * bitmap;
cGLCD();
~cGLCD();
uint32_t ColorConvert3to1(uint32_t red, uint32_t green, uint32_t blue);
void DeInit();
void Rescan();
bool showProgressBarBorder(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, uint32_t scale, uint32_t color_border, uint32_t color_progress);
bool imageShow(const std::string & filename, uint32_t dx, uint32_t dy, uint32_t dw, uint32_t dh, bool transp = false, bool maximize = false, bool clear = false, bool center_sw = false, bool center_sh = false);
bool drawText(int x, int y, int xmax, int text_width, const std::string & text, const GLCD::cFont * font, uint32_t color1, uint32_t color2, bool proportional, int skipPixels, int align);
static cGLCD *getInstance();
static void lockChannel(std::string txt, std::string epg = "", int scale = 0);
static void unlockChannel();
static void lockTime(std::string time);
static void unlockTime();
static void lockDuration(std::string time);
static void unlockDuration();
static void lockStart(std::string time);
static void unlockStart();
static void lockEnd(std::string time);
static void unlockEnd();
static void lockIcon(int type = 0);
static void unlockIcon(int type = 0);
static void MirrorOSD(bool b = true);
static void Update();
static void Suspend();
static void StandbyMode(bool);
static void ShowVolume(bool);
static void ShowLcdIcon(bool);
static void Resume();
static void Exit();
static void Blit();
static void SetBrightness(unsigned int b);
static void TogglePower();
bool dumpBuffer(fb_pixel_t *s, int format, const char *filename);
void UpdateBrightness();
int handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data);
};
#endif
#endif

View File

@@ -0,0 +1,74 @@
/*
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

@@ -0,0 +1,34 @@
/*
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

@@ -0,0 +1,74 @@
/*
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

@@ -0,0 +1,34 @@
/*
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

@@ -0,0 +1,74 @@
/*
simple 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 "simpleclock.h"
static bool fonts_initialized = false;
GLCD::cFont font_time_standby;
void InitSimpleClock(void)
{
printf("[%s:%s] finish initialization\n", __file__, __func__);
}
void SimpleClockUpdateFonts(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 (!font_time_standby.LoadFT2(t.glcd_font, "UTF-8", fontsize_time_standby)) {
t.glcd_font = FONTDIR "/neutrino.ttf";
font_time_standby.LoadFT2(t.glcd_font, "UTF-8", fontsize_time_standby);
}
}
fonts_initialized = true;
}
void RenderSimpleClock(std::string Time, int x, int y)
{
cGLCD *cglcd = cGLCD::getInstance();
SNeutrinoGlcdTheme &t = g_settings.glcd_theme;
SimpleClockUpdateFonts();
cglcd->bitmap->DrawText(std::max(2,(cglcd->bitmap->Width() - 4 - font_time_standby.Width(Time))/2),
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);
}
void ShowSimpleClock(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() - font_time_standby.Height(Time)) / 2;
RenderSimpleClock(Time, 255, y);
}

View File

@@ -0,0 +1,34 @@
/*
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 InitSimpleClock();
void SimpleClockUpdateFonts();
void RenderSimpleClock(std::string Time, int x, int y);
void ShowSimpleClock(std::string Time);

270
src/driver/glcd/weather.cpp Normal file
View File

@@ -0,0 +1,270 @@
/*
weather - 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.
*/
#include <config.h>
#include <cstdio>
#include "weather.h"
#include <gui/weather.h>
#include <system/helpers.h>
enum weathers
{
CLEAR_DAY = 0,
CLEAR_NIGHT = 1,
CLOUDY = 2,
FOG = 3,
PARTLY_CLOUDY_DAY = 4,
PARTLY_CLOUDY_NIGHT = 5,
RAIN = 6,
SLEET = 7,
SNOW = 8,
WIND = 9,
//WEATHER_UNKNOWN = 10
};
const char * const weather_name[LCD_NUMBER_OF_WEATHERS] =
{
"clear-day",
"clear-night",
"cloudy",
"fog",
"partly-cloudy-day",
"partly-cloudy-night",
"rain",
"sleet",
"snow",
"wind",
//"unknown"
};
#define NUMBER_OF_PATHS 2
const char * const weather_path[NUMBER_OF_PATHS] =
{
LCDDIR_VAR "/oled/weather/",
DATADIR "/oled/weather/"
};
static bool ForceUpdate = true;
static bool fonts_initialized = false;
GLCD::cFont font_temperature;
static std::string weather[LCD_NUMBER_OF_WEATHERS] = {""};
static std::string st_current_wcity = "";
static std::string st_current_wtimestamp = "";
static std::string st_current_wtemp = "";
static std::string st_current_wwind = "";
static std::string st_current_wicon = "";
static std::string st_next_wcity = "";
static std::string st_next_wtimestamp = "";
static std::string st_next_wtemp = "";
static std::string st_next_wwind = "";
static std::string st_next_wicon = "";
void InitWeather(void)
{
for (int i = 0; i < LCD_NUMBER_OF_WEATHERS; i++)
{
std::string weather_file;
for (int j = 0; j < NUMBER_OF_PATHS; j++)
{
std::string file_jpg = weather_path[j];
file_jpg += weather_name[i];
file_jpg += ".jpg";
if (file_exists(file_jpg.c_str()))
{
weather_file = file_jpg;
goto found;
}
std::string file_jpeg = weather_path[j];
file_jpeg += weather_name[i];
file_jpeg += ".jpeg";
if (file_exists(file_jpeg.c_str()))
{
weather_file = file_jpeg;
goto found;
}
std::string file_png = weather_path[j];
file_png += weather_name[i];
file_png += ".png";
if (file_exists(file_png.c_str()))
{
weather_file = file_png;
goto found;
}
std::string file_bmp = weather_path[j];
file_bmp += weather_name[i];
file_bmp += ".bmp";
if (file_exists(file_bmp.c_str()))
{
weather_file = file_bmp;
goto found;
}
std::string file_gif = weather_path[j];
file_gif += weather_name[i];
file_gif += ".gif";
if (file_exists(file_gif.c_str()))
{
weather_file = file_gif;
goto found;
}
}
found:
printf("[%s:%s] found file: %s\n", __file__, __func__, weather_file.c_str());
weather[i] += std::string(weather_file);
}
printf("[%s:%s] finish initialization\n", __file__, __func__);
}
void WeatherUpdateFonts(void)
{
cGLCD *cglcd = cGLCD::getInstance();
SNeutrinoGlcdTheme &t = g_settings.glcd_theme;
int fontsize_temperature = 0;
int percent_temperature = std::min(24, 100);
int fontsize_temperature_new = percent_temperature * cglcd->lcd->Height() / 100;
if (!fonts_initialized || (fontsize_temperature_new != fontsize_temperature)) {
fontsize_temperature = fontsize_temperature_new;
if (!font_temperature.LoadFT2(/*t.glcd_font*/FONTDIR "/pakenham.ttf", "UTF-8", fontsize_temperature)) {
t.glcd_font = FONTDIR "/pakenham.ttf";
font_temperature.LoadFT2(t.glcd_font, "UTF-8", fontsize_temperature);
}
}
fonts_initialized = true;
}
int WeatherNameToNumber(std::string name)
{
std::map<std::string, int> weather_name
{
{ "clear-day", 0 },
{ "clear-night", 1 },
{ "cloudy", 2 },
{ "fog", 3 },
{ "partly-cloudy-day", 4 },
{ "partly-cloudy-night", 5 },
{ "rain", 6 },
{ "sleet", 7 },
{ "snow", 8 },
{ "wind", 9 },
//{ "unknown", 10 },
};
const auto iter = weather_name.find(name);
if (iter != weather_name.cend())
return iter->second;
}
void RenderWeather(int cx, int cy, int nx, int ny, bool standby)
{
int forecast = 0;
std::string current_wcity = "";
std::string current_wtimestamp = "";
std::string current_wtemp = "";
std::string current_wwind = "";
std::string current_wicon = "";
std::string next_wcity = "";
std::string next_wtimestamp = "";
std::string next_wtemp = "";
std::string next_wwind = "";
std::string next_wicon = "";
cGLCD *cglcd = cGLCD::getInstance();
SNeutrinoGlcdTheme &t = g_settings.glcd_theme;
if (g_settings.weather_enabled)
{
if (CWeather::getInstance()->checkUpdate(ForceUpdate))
{
current_wcity = st_current_wcity = CWeather::getInstance()->getCity();
current_wtimestamp = st_current_wtimestamp = to_string((int)CWeather::getInstance()->getCurrentTimestamp());
current_wtemp = st_current_wtemp = CWeather::getInstance()->getCurrentTemperature();
current_wwind = st_current_wwind = CWeather::getInstance()->getCurrentWindSpeed();
current_wicon = st_current_wicon = CWeather::getInstance()->getCurrentIconOnlyName();
next_wcity = st_next_wcity = CWeather::getInstance()->getCity();
next_wtimestamp = st_next_wtimestamp = to_string((int)CWeather::getInstance()->getForecastWeekday(forecast));
next_wtemp = st_next_wtemp = CWeather::getInstance()->getForecastTemperatureMin(forecast);
next_wtemp = st_next_wtemp += "|" + CWeather::getInstance()->getForecastTemperatureMax(forecast);
next_wwind = st_next_wwind = CWeather::getInstance()->getForecastWindBearing(forecast);
next_wicon = st_next_wicon = CWeather::getInstance()->getForecastIconOnlyNane(forecast);
}
else
{
current_wcity = st_current_wcity;
current_wtimestamp = st_current_wtimestamp;
current_wtemp = st_current_wtemp;
current_wwind = st_current_wwind;
current_wicon = st_current_wicon;
next_wcity = st_next_wcity;
next_wtimestamp = st_next_wtimestamp;
next_wtemp = st_next_wtemp;
next_wwind = st_next_wwind;
next_wicon = st_next_wicon;
}
if (current_wicon != "") {
if (!standby)
cglcd->imageShow(weather[WeatherNameToNumber(current_wicon)], cx, cy, 64, 64, false, false, false, false, false);
else
cglcd->imageShow(weather[WeatherNameToNumber(current_wicon)], cx, cy, 0, 0, false, false, false, false, false);
}
if (current_wtemp != "") {
current_wtemp += "°";
WeatherUpdateFonts();
cglcd->bitmap->DrawText(170, 240, cglcd->bitmap->Width() - 1, current_wtemp,
&font_temperature, cglcd->ColorConvert3to1(t.glcd_color_fg_red, t.glcd_color_fg_green, t.glcd_color_fg_blue), GLCD::cColor::Transparent);
}
if (next_wicon != "") {
if (!standby)
cglcd->imageShow(weather[WeatherNameToNumber(next_wicon)], nx, ny, 64, 64, false, false, false, false, false);
else
cglcd->imageShow(weather[WeatherNameToNumber(next_wicon)], nx, ny, 0, 0, false, false, false, false, false);
}
if (next_wtemp != "") {
next_wtemp += "°";
WeatherUpdateFonts();
cglcd->bitmap->DrawText(270, 240, cglcd->bitmap->Width() - 1, next_wtemp,
&font_temperature, cglcd->ColorConvert3to1(t.glcd_color_fg_red, t.glcd_color_fg_green, t.glcd_color_fg_blue), GLCD::cColor::Transparent);
}
}
}
void ShowWeather(bool standby)
{
SNeutrinoGlcdTheme &t = g_settings.glcd_theme;
if (!standby) {
RenderWeather(t.glcd_weather_x_position_current, t.glcd_weather_y_position, t.glcd_weather_x_position_next, t.glcd_weather_y_position, standby);
} else {
RenderWeather(t.glcd_weather_x_position_current_standby, t.glcd_weather_y_position_standby, t.glcd_weather_x_position_next_standby, t.glcd_weather_y_position_standby, standby);
}
if (ForceUpdate)
ForceUpdate = false;
}

39
src/driver/glcd/weather.h Normal file
View File

@@ -0,0 +1,39 @@
/*
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"
#define LCDDIR_VAR "/usr/share/tuxbox/neutrino/icons"
#define LCD_NUMBER_OF_WEATHERS 10
void InitWeather();
void WeatherUpdateFonts();
int WeatherNameToNumber(std::string name);
void RenderWeather(int cx, int cy, int nx, int ny, bool standby);
void ShowWeather(bool standby);