summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9562da1)
raw | patch | inline | side by side (parent: 9562da1)
author | EricDWertz <EricDWertz@gmail.com> | |
Tue, 26 Apr 2016 03:53:33 +0000 (23:53 -0400) | ||
committer | EricDWertz <EricDWertz@gmail.com> | |
Tue, 26 Apr 2016 03:53:33 +0000 (23:53 -0400) |
config.h file that will hold basic configurations
config.h | [new file with mode: 0644] | patch | blob |
main.c | patch | blob | history |
diff --git a/config.h b/config.h
--- /dev/null
+++ b/config.h
@@ -0,0 +1,44 @@
+/* deskclocky config.h file
+ * Main program options go here
+ */
+
+#define WINDOW_WIDTH 1280
+#define WINDOW_HEIGHT 800
+
+#define FONT_SIZE 64.0
+#define GRID_SIZE FONT_SIZE*1.5
+
+#define URL_BASE "http://api.wunderground.com/api/565b48be709c806d/"
+#define URL_POSTFIX "/q/40.4598,-78.5917.json"
+
+//10 minute timeout to refresh weather info
+#define WEATHER_REFRESH_TIMEOUT 600
+
+#define DEBUG_TIMESCALE 0
+
+char* weekday_names[7] =
+{
+ "Sunday",
+ "Monday",
+ "Tuesday",
+ "Wednesday",
+ "Thursday",
+ "Friday",
+ "Saturday"
+};
+
+char* month_names[12] =
+{
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December"
+};
index d6b1e3268a7dbaadf567dc2117384bbe86474609..6c958165e82d097fdaebbc7d22ce17bcf94e2598 100644 (file)
--- a/main.c
+++ b/main.c
#include <curl/curl.h>
#include <jansson.h>
-#define WINDOW_WIDTH 1280
-#define WINDOW_HEIGHT 800
+#include "config.h"
-#define FONT_SIZE 64.0
-#define GRID_SIZE FONT_SIZE*1.5
-
-#define URL_BASE "http://api.wunderground.com/api/565b48be709c806d/"
-#define URL_POSTFIX "/q/40.4598,-78.5917.json"
-
-//10 minute timeout to refresh weather info
-#define WEATHER_REFRESH_TIMEOUT 600
int weather_update_timer = WEATHER_REFRESH_TIMEOUT;
cairo_surface_t* temp_surface;
-char* weekday_names[7] =
-{
- "Sunday",
- "Monday",
- "Tuesday",
- "Wednesday",
- "Thursday",
- "Friday",
- "Saturday"
-};
-
-char* month_names[12] =
-{
- "January",
- "February",
- "March",
- "April",
- "May",
- "June",
- "July",
- "August",
- "September",
- "October",
- "November",
- "December"
-};
GtkWidget* window;
GdkPixbuf* background_pixbuf;
cairo_set_line_width( cr, 2.0 );
cairo_set_operator( cr, CAIRO_OPERATOR_SOURCE );
cairo_set_source_rgba( cr, 1.0, 1.0, 1.0, 0.0 );
- cairo_arc( cr, x, y, r, 0, 2.0 * M_PI );
+ cairo_arc( cr, x, y, r + 8.0, 0, 2.0 * M_PI );
cairo_fill( cr );
cairo_set_operator( cr, CAIRO_OPERATOR_OVER );
double hour = (double)timeinfo->tm_hour * 6.0 + ( (double)timeinfo->tm_min / 10.0 );
int hour_min = floor( hour );
int hour_max = ceil( hour );
- printf( "Current hour: %f\n", hour );
+ if( hour_max > 143 ) hour_max = 143;
+
cairo_set_operator( cr, CAIRO_OPERATOR_SOURCE );
cairo_set_line_width( cr, 8.0 );
cairo_rectangle( cr, 0, WINDOW_HEIGHT - GRID_SIZE, WINDOW_WIDTH, GRID_SIZE );
cairo_fill( cr );
+ double sun_x, sun_y, altitude;
+ altitude = astro_info[hour_min].sun_altitude + ( astro_info[hour_max].sun_altitude - astro_info[hour_min].sun_altitude ) * (hour - hour_min );
+ sun_x = hour * ((double)WINDOW_WIDTH / 143.0);
+ sun_y = WINDOW_HEIGHT - GRID_SIZE - ( altitude / 90.0 ) * ( WINDOW_HEIGHT - GRID_SIZE * 2.0 );
+ draw_sun_icon( cr, sun_x, sun_y, FONT_SIZE * 0.5 );
+
cairo_set_operator( cr, CAIRO_OPERATOR_OVER );
}
cairo_set_source_surface( cr, temp_surface, 0, 0 );
cairo_paint( cr );
- draw_sun_icon( cr, 100, 100, FONT_SIZE * 0.5 );
-
/*
* This part draws the background rectangles
* TODO: make it so the shade rectangles are drawn on their own surface then overlayed on the background pixbuf
time_t rawtime;
time ( &rawtime );
- timeinfo = localtime ( &rawtime );
+ //timeinfo = localtime ( &rawtime );
+ timeinfo->tm_min+=1;
+ if( timeinfo->tm_min > 59 )
+ {
+ timeinfo->tm_min = 0;
+ timeinfo->tm_hour += 1;
+ if( timeinfo->tm_hour > 23 )
+ timeinfo->tm_hour = 0;
+ }
weather_update_timer--;
if( weather_update_timer < 0 )
* Load test pixbuf
* TODO: Make this so it randomly selects images from a directory based on current time of day/sun state
*/
- load_background_pixbuf( "test.jpg" );
+ load_background_pixbuf( "/home/eric/deskclocky/test.jpg" );
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_window_set_title(GTK_WINDOW(window), "Alpha Demo");
time ( &rawtime );
timeinfo = localtime ( &rawtime );
- g_timeout_add_seconds(1,refresh_clock,NULL);
+ //g_timeout_add_seconds(1,refresh_clock,NULL);
+ g_timeout_add( 100, refresh_clock, NULL );
update_weather();
temp_surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, WINDOW_WIDTH, WINDOW_HEIGHT );