Ver código fonte

resolves #1

* quick dim button on 'ui_main' in html
* in html, added 'screen' so button presses won't
  trigger a stray fare acceptance by covering screen
  in big button
* javascript functions to make api request
* api request added to diu_minder
* for now, assumes root and issues an 'xset' to dim the screen
Abram Connelly 6 anos atrás
pai
commit
48ffd316b3

+ 26 - 0
busunit/DIUv2/diu_main.c

@@ -900,6 +900,28 @@ static void ui_handle_driver_login(struct mg_connection *nc, struct http_message
       (unsigned long)strlen(msg_success), msg_success);
 }
 
+// screen dim event
+//
+static void ui_handle_dim(struct mg_connection *nc, struct http_message *hm) {
+  int ret;
+
+  char msg_fail[] = "fail dim";
+  char msg_success[] = "ok dim";
+
+  // assuming we're running as root for now
+  //
+  ret = system("su - pi -c \"/usr/bin/xset -display :0 dpms force off\"");
+
+  if (ret!=0) {
+    mg_printf(nc, "HTTP/1.1 200 OK\r\nContent-Length: %lu\r\n\r\n%s",
+        (unsigned long)strlen(msg_fail), msg_fail);
+    return;
+  }
+
+  mg_printf(nc, "HTTP/1.1 200 OK\r\nContent-Length: %lu\r\n\r\n%s",
+      (unsigned long)strlen(msg_success), msg_success);
+}
+
 
 
 // api point
@@ -946,6 +968,10 @@ static void api_handle_req(struct mg_connection *nc, struct http_message *hm) {
     ui_handle_fare_input(nc, hm);
   }
 
+  else if (strncmp(s_action, "dim", strlen("dim"))==0) {
+    ui_handle_dim(nc, hm);
+  }
+
   else {
     mg_http_send_error(nc, 404, NULL);
   }

+ 20 - 69
busunit/DIUv2/html/css/diustyles.css

@@ -25,9 +25,7 @@ html, body {
 body {
   background: #efefef;
   color: hsl(240,30,10);
-  /* letter-spacing: 0.125em; */
   text-align: center;
-  /* text-transform: uppercase; */
 
   -webkit-touch-callout: none; /* iOS Safari */
     -webkit-user-select: none; /* Safari */
@@ -82,7 +80,6 @@ p:focus {
 */
 
 .statuslogin {
-  /* font-size:20px; */
   resize:none;
   background: #f7f7f7;
   overflow:hidden;
@@ -99,14 +96,8 @@ p:focus {
 }
 
 .statusmain {
-  /* font-size:20px; */
   resize:none;
   background: #f7f7f7;
-  /*
-  overflow:auto;
-  overflow-x:hidden;
-  overflow-y:hidden;
-  */
   word-wrap:off;
   -webkit-user-select: none;
   -webkit-touch-callout: none;
@@ -118,16 +109,9 @@ p:focus {
   -moz-user-select: none;
 }
 
-@media only screen and (max-width: 640px) {
-  body {
-    background: rgb(230,230,230);
-  }
-}
-
-@media only screen and (min-width: 640px) {
-  body {
-    background: lightblue;
-  }
+.bkeyFull {
+  width: 96vw;
+  height:96vh;
 }
 
 /* small size */
@@ -181,6 +165,11 @@ p:focus {
     height:75px;
   }
 
+  .bkeyNarrow {
+    width: 75px;
+    height:75px;
+  }
+
 
   .bkeyw {
     width: 150px;
@@ -226,11 +215,6 @@ p:focus {
   .col { width: 160px; }
 
   .bdisp {
-    /*
-    font-size: 40px;
-    margin-top: 30px;
-    margin-right: 30px;
-    */
     font-size: 7vh;
     margin-top: 5vh;
     margin-right: 1vw;
@@ -249,14 +233,12 @@ p:focus {
   }
 
   .bdrop {
-    /* font-size: 38px; */
     font-size: 7vh;
     border: solid 4px #888888;
     box-shadow: 6px 6px 0px #aaaaaa;
   }
 
   .bdropinp {
-    /* font-size: 44px; */
     font-size: 7vh;
     border: solid 4px #888888;
     box-shadow: 6px 6px 0px #aaaaaa;
@@ -267,6 +249,16 @@ p:focus {
     height:20vh;
   }
 
+  .bkeyFull {
+    width: 96vw;
+    height:96vh;
+  }
+
+  .bkeyNarrow {
+    width: 10vw;
+    height:40vh;
+  }
+
 
   .bkeyw {
     width: 25vw;
@@ -295,16 +287,8 @@ p:focus {
 }
 
 .bdisp {
-
-  /* font-size: 20px; */
   font-weight: bold;
   color: #444444;
-
-  /*
-  margin-top: 15px;
-  margin-right: 15px;
-  */
-
   margin-left: auto;
 
   background: none;
@@ -313,17 +297,9 @@ p:focus {
 
 
 .bmsg {
-
-  /* font-size: 20px; */
   font-weight: bold;
   color: #444444;
-
   background: #ADD8E6;
-  /*
-  border: solid 2px #888888;
-  box-shadow: 3px 3px 0px #aaaaaa;
-  */
-
 }
 
 .bmsg:focus {
@@ -331,16 +307,8 @@ p:focus {
 }
 
 .bstatus {
-
-  /* font-size: 20px; */
   font-weight: bold;
   color: #444444;
-
-  /*
-  border: solid 2px #888888;
-  box-shadow: 3px 3px 0px #aaaaaa;
-  */
-
 }
 
 .bstatus:focus {
@@ -349,19 +317,9 @@ p:focus {
 
 
 .bdrop {
-
-  /*
-  font-size: 19px;
-  */
   font-weight: bold;
   color: #444444;
-
   background: none;
-  /*
-  border: solid 2px #888888;
-  box-shadow: 3px 3px 0px #aaaaaa;
-  */
-
 }
 
 .bdrop:focus {
@@ -370,16 +328,9 @@ p:focus {
 
 
 .bdropinp {
-
-  /* font-size: 22px; */
   font-weight: bold;
   color: #444444;
-
   background: none;
-  /*
-  border: solid 2px #888888;
-  box-shadow: 3px 3px 0px #aaaaaa;
-  */
 
   -webkit-transition: margin-left 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
   -moz-transition: margin-left 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
@@ -457,7 +408,7 @@ p:focus {
   top: 5%;
   */
 
-  left: 75vw;
+  left: 85vw;
   top: 5vh;
 }
 
@@ -469,7 +420,7 @@ p:focus {
   top: 35%;
   */
 
-  left: 75vw;
+  left: 85vw;
   top: 30vh;
 }
 

+ 39 - 14
busunit/DIUv2/html/index-ORG.html

@@ -343,6 +343,26 @@ Diagnostic window...
 
 
 
+    </div>
+
+    <!-- ************************* -->
+    <!-- ******            ******* -->
+    <!-- ******    Dim     ******* -->
+    <!-- ******            ******* -->
+    <!-- ************************* -->
+
+    <div id='ui_dim' style='display:none;'>
+
+      <div style='width:100%; height:100%;'>
+
+        <div class='pure-g row' style='width:100%; height:100%;' >
+          <div class='pure-u-1-6 col' style=' position:absolute; top:2%; margin-left:2%; '>
+            <button onmousedown='_beep();' class='bdropinp bkeyFull' id='ui_dim_btn'>Quick Dim Function, press anywhere to go back</button>
+          </div>
+        </div>
+
+      </div>
+
     </div>
 
     <!-- ************************* -->
@@ -356,20 +376,25 @@ Diagnostic window...
 
       <div class='pure-g row4'>
 
-        <button class='invisiblock' id='ui_main_blockwindow'> </button>
-
-        <textarea
-          wrap=""
-          class='statusmain'
-          type='textarea'
-          id='ui_main_status'
-          rows='10'
-          cols='40'
-          onselect='return false;'
-          unselectable='on'
-          disabled readonly>
-        ...
-        </textarea>
+        <div class='pure-u-1-6 col'>
+          <button class='bdropinp bkeyNarrow' onmousedown='_beep();' id='ui_main_dim'>DIM</button>
+        </div>
+
+        <div class='pure-u-1-2 col'>
+          <button class='invisiblock' id='ui_main_blockwindow'> </button>
+          <textarea
+            wrap=""
+            class='statusmain'
+            type='textarea'
+            id='ui_main_status'
+            rows='10'
+            cols='40'
+            onselect='return false;'
+            unselectable='on'
+            disabled readonly>
+          ...
+          </textarea>
+        </div>
 
         <!-- <div class='pure-u-1-2 col'> <button onmousedown='_beep();' class='bstatus' id='ui_main_status'>status...</button> </div> -->
 

+ 17 - 0
busunit/DIUv2/html/js/diu_ui-ORG.js

@@ -411,6 +411,17 @@ function _main_nxt() {
   _api_request("nextstop");
 }
 
+function _main_dim() {
+  console.log("dim...");
+  _api_request("dim");
+  _switch_ui('ui_dim');
+}
+
+function _dim_wakeup() {
+  console.log("waking up from dim");
+  _switch_ui("ui_main");
+}
+
 function _fare_adult() {
   console.log("fare adult");
   _api_request("fare", {"rule":"CASH-ADULT", "param":"", "fare":"adult","count":1});
@@ -903,6 +914,12 @@ function init() {
   document.getElementById('ui_main_bulk').onclick = _main_bulk;
   document.getElementById('ui_main_menu').onclick = _main_menu;
 
+  document.getElementById('ui_main_dim').onclick = _main_dim;
+
+  // dim
+  //
+  document.getElementById('ui_dim_btn').onclick = _dim_wakeup;
+
   var simple_fares   = [ "adult", "youth", "half", "bike", "wheelchair", "transfer"];
   var simple_fares_f = [ _fare_adult, _fare_youth, _fare_half, _fare_bike, _fare_wheelchair, _fare_transfer];
   for (var ii=0; ii<simple_fares.length; ii++) {