stable now, graphs might need some tweaks
authorLance Colton <lance.colton@gmail.com>
Tue, 13 Mar 2012 01:48:20 +0000 (19:48 -0600)
committerLance Colton <lance.colton@gmail.com>
Tue, 13 Mar 2012 01:48:20 +0000 (19:48 -0600)
data/box.lua
data/graph.lua
data/text.lua
src/bme.c
src/linux.c

index 81f84e5..dd95c27 100644 (file)
@@ -54,10 +54,19 @@ table_settings={
         radius=20,
     },
     {   
-        x=700,
+        x=610,
         y=100,
-        h=90,
-        w=150,
+        h=86,
+        w=240,
+        linear_gradient = {300,200,550,350},
+        colour = {{0,0x000000,0.2},{1,0x000000,0.1}},
+        radius=20,
+    },
+    {   
+        x=350,
+        y=100,
+        h=86,
+        w=250,
         linear_gradient = {300,200,550,350},
         colour = {{0,0x000000,0.2},{1,0x000000,0.1}},
         radius=20,
index 00c65ed..055e11b 100644 (file)
@@ -206,37 +206,57 @@ function set_settings()
                        name="to_bytes ${diskio",
                        arg="mmcblk0}",
                        max=2500000,
-                       y=187,
-                       x=690,
+                       y=183,
+                       x=349,
                        autoscale=true,
-                       width=160,
+                       width=250,
                        height=89,
-                       nb_values=130,
+                       nb_values=125,
                        fg_bd_size=0,
                        bg_colour = {{0,0x667AF6,0},{1,0x000000,0}},
-                       fg_bd_colour =  { {0,0xdd0000,1},{0.5,0xdddd00,1},{1,0xFFFF00,1}},
-                       fg_colour = { {1,0x111111,0.3},{0.5,0x33cc00,0.6},{0,0x00FF00,0.8}},
+                       fg_bd_colour =  { {0,0x111111,0.3},{0.5,0xcc6600,0.6},{1,0xcc6600,0.8}},
+                       fg_colour = { {1,0x111111,0.3},{0.5,0xcc6600,0.6},{0,0xcc6600,0.8}},
                        foreground=true,
                        bg_orientation="ne",
                        fg_orientation="ee",
            },
            {
-                       name="battery_rate",
+                       name="battery_rate", --displays when discharging
                        arg="",
-                       max=350,
-                       y=187,
-                       x=500,
+                       max=500,
+                       y=183,
+                       x=593,
                        autoscale=true,
-                       width=160,
-                       height=45,
-                       nb_values=130,
+                       width=250,
+                       height=85,
+                       nb_values=125,
                        fg_bd_size=0,
                        bg_colour = {{0,0x667AF6,0},{1,0x000000,0}},
-                       fg_bd_colour =  { {0,0xdd0000,1},{0.5,0xdddd00,1},{1,0xFFFF00,1}},
-                       fg_colour = { {1,0x111111,0.3},{0.5,0x33cc00,0.6},{0,0x00FF00,0.8}},
+                       fg_bd_colour =  { {0,0xFF0000,1},{0.5,0xFF0000,1},{1,0xFF0000,1}},
+                       fg_colour = { {1,0xFF0000,0.3},{0.5,0xFF0000,0.6},{0,0xFF0000,0.8}},
                        foreground=true,
                        bg_orientation="ne",
                        fg_orientation="ee",
+                       DrawMe="${if_match ${battery_rate} > 0}1${else}0$endif",
+           },
+           {
+                       name="battery_rate", --displays when charging
+                       arg="",
+                       max=500,
+                       y=183,
+                       x=593,
+                       autoscale=true,
+                       width=250,
+                       height=85,
+                       nb_values=125,
+                       fg_bd_size=0,
+                       bg_colour = {{0,0x667AF6,0},{1,0x000000,0}},
+                       fg_bd_colour =  { {0,0x00FF00,1},{0.5,0x00FF00,1},{1,0x00FF00,1}},
+                       fg_colour = { {1,0x00FF00,0.3},{0.5,0x00FF00,0.6},{0,0x00FF00,0.8}},
+                       foreground=true,
+                       bg_orientation="ne",
+                       fg_orientation="ee",
+                       DrawMe="${if_match ${battery_rate} < 0}1${else}0$endif",
            },
     }
 end
@@ -282,7 +302,7 @@ function conky_main_graph()
                        --beginning point
                        graph_settings[i].beg = graph_settings[i].nb_values
                        --graph_settings[i].beg = 0
-                       for j =1, graph_settings[i].nb_values do
+                       for j=1, graph_settings[i].nb_values do
                            graph_settings[i].values[j]=0
                        end
                  graph_settings[i].flag_init=true
@@ -316,6 +336,7 @@ function conky_main_graph()
                                        value=tonumber(conky_parse('${' .. 
                                            graph_settings[i].name .. " " ..
                                            graph_settings[i].arg ..'}'))
+                                       value=math.abs(value)
                        end
                                        graph_settings[i].values[nb_values]=value
                                end
index 8b18bc0..6714e0b 100644 (file)
@@ -177,7 +177,7 @@ function conky_draw_text()
                reflection_length=0,                    
         },  
         {
-                   text=conky_parse('${memperc}').."%",
+                   text=conky_parse('${memperc}').."% RAM",
                    x=223,
                    y=101,
                    v_align="t",
@@ -264,8 +264,35 @@ function conky_draw_text()
                                reflection_alpha=0,
                                reflection_length=0,
                                DrawMe=conky_parse("${if_mounted /home/user/MyDocs}1$endif")
+        },        
+        {
+                   text="DiskIO",
+                   x=520,
+                   y=101,
+                   v_align="t",
+                   font_name="Nokia Pure",
+                   font_size=18,
+                       colour={{0,0xcc6600,1},{1,col0,1}},
+                       bold=true,
+                               orientation="ww",
+                               reflection_alpha=0,
+                               reflection_length=0,
+        },
+        {
+                   text="Charge Rate",
+                   x=720,
+                   y=101,
+                   v_align="t",
+                   font_name="Nokia Pure",
+                   font_size=18,
+                       colour={{0,0xFF0000,1},{1,col0,1}},
+                       bold=true,
+                               orientation="ww",
+                               reflection_alpha=0,
+                               reflection_length=0,
         },
- --[[       {
+        
+ --[[   {
                    text=conky_parse('${fs_used /media/mmc1} / ${fs_size /media/mmc1} (${fs_free /media/mmc1})'),
                    x=5,
                    y=175,
index ba399f0..5815e99 100644 (file)
--- a/src/bme.c
+++ b/src/bme.c
@@ -73,14 +73,13 @@ static void dumpBuffer(const void *buf, size_t bufSize)
 
 const char* bmeClientGetData(const char *bmeSocketPath, struct bme_reply *bmeReply)
 {
-  static int x = 0;
-  printf("%d\n", x); // outputs the value of x //always crashes on 23 or 24
-  x = x + 1;
+  //static int x = 0;
+  //printf("%d\n", x); // outputs the value of x //always crashes on 23 or 24
+  //x = x + 1;
     
   int s = socket(AF_LOCAL, SOCK_STREAM, 0);
   if (s <= 0)
     return "socket";
-  NORM_ERR("bme a");
   struct sockaddr_un name;
   name.sun_family = AF_LOCAL;
   strcpy(name.sun_path, bmeSocketPath);
@@ -89,29 +88,26 @@ const char* bmeClientGetData(const char *bmeSocketPath, struct bme_reply *bmeRep
 
   char foo[256];
   size_t rd;
-  NORM_ERR("bme b");
   // TODO: clean up this crap
   write(s, "SYNC\10\0\0\0BMentity", 16);
   rd = read(s, foo, sizeof(foo));
-  NORM_ERR("read %i bytes",rd); //reads 0 right before it crashes
+  //NORM_ERR("read %i bytes",rd); //reads 9 every time
   //fprintf(stderr, "rd=%zu\n", rd);
-  NORM_ERR("bme c");
   write(s, "SYNC\4\0\0\0\3\200\0\0\n", 12);//crashes here
-  NORM_ERR("bme c.5");
   rd = read(s, foo, 20);
-  NORM_ERR("bme d");
-  NORM_ERR("read %i bytes",rd); //reads 0 right before it crashes
+  //NORM_ERR("bme socket read %i bytes",rd); //reads -1 right before it crashes
   //fprintf(stderr, "rd=%zu\n", rd);
   rd = read(s, bmeReply, sizeof(*bmeReply));
   //fprintf(stderr, "rd=%zu\n", rd);
-  NORM_ERR("bme e");
   // FIXME: sometimes we get extra data in replies
-  NORM_ERR("read %i bytes",rd); //reads 0 right before it crashes
+  //NORM_ERR("read %i bytes",rd); //reads 0 right before it crashes
   if (rd > 128){
     memmove( bmeReply, ((char*) bmeReply) + rd - 128, 128);
   }
-  dumpBuffer(bmeReply, rd);
-
+ // dumpBuffer(bmeReply, rd);
+  close(s);
   return 0;
 }
 
@@ -131,9 +127,9 @@ struct bme_reply getBattInfoFromBME()
   struct bme_reply bmeReply;
   
   memset(&bmeReply, 0, sizeof bmeReply);
-  NORM_ERR("bme 1");
+  //NORM_ERR("bme 1");
   const char *failedOn = bmeClientGetData("/tmp/.bmesrv", &bmeReply);
-  NORM_ERR("bme 2");
+  //NORM_ERR("bme 2");
   if (failedOn) {
     NORM_ERR("bme_client_get_data failed on %s: %s\n", failedOn, strerror(errno));
     //try again
index d021cd4..0dd4bcd 100644 (file)
@@ -1920,12 +1920,10 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat, int item)
        idx = get_battery_idx(bat);
 
        /* don't update battery too often */
-/*
        if (current_update_time - last_battery_time[idx] < 2) {
                set_return_value(buffer, n, item, idx);
                return;
        }
-*/
 
        last_battery_time[idx] = current_update_time;
 
@@ -2006,11 +2004,9 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat, int item)
                 }
                 
                 struct bme_reply bmeInfo = getBattInfoFromBME();
-                NORM_ERR("at linux.c bme 3");
                 last_battery_temp[idx] = ((float)bmeInfo.battery_temperature) - 273.15f;
                 last_battery_rate[idx] = bmeInfo.battery_current;
-               //last_battery_temp[idx] = temp;
-                NORM_ERR("at linux.c bme 4");
+               //last_battery_temp[idx] = temp;                
        }
        set_return_value(buffer, n, item, idx);
 }